﻿#include "color/colors.h"
#include <iostream>

using namespace anip;
using namespace std;

template<>
void anip::binaryWrite(const color& val, ostream& o)
{
	binaryWrite(val.r, o);
	binaryWrite(val.g, o);
	binaryWrite(val.b, o);
	binaryWrite(val.a, o);
}

template<>
void anip::binaryRead(color& val, istream& o)
{
	binaryRead(val.r, o);
	binaryRead(val.g, o);
	binaryRead(val.b, o);
	binaryRead(val.a, o);
}

wstring anip::toString(const color& x)
{
	static char buf[100];
	snprintf(buf, sizeof(buf), "(%.3f, %.3f, %.3f, %.3f)", x.r, x.g, x.b, x.a);
	return utf8s2ws(buf);
}
const color Colors::transparent = { 0.0f, 0.0f, 0.0f, 0.0f };

const color Colors::aliceBlue = { 0.941f, 0.973f, 1.0f, 1.0f };
const color Colors::antiqueWhite = { 0.98f, 0.922f, 0.843f, 1.0f };
const color Colors::aqua = { 0.0f, 1.0f, 1.0f, 1.0f };
const color Colors::aquamarine = { 0.498f, 1.0f, 0.831f, 1.0f };
const color Colors::azure = { 0.941f, 1.0f, 1.0f, 1.0f };
const color Colors::beige = { 0.961f, 0.961f, 0.863f, 1.0f };
const color Colors::bisque = { 1.0f, 0.894f, 0.769f, 1.0f };
const color Colors::black = { 0.0f, 0.0f, 0.0f, 1.0f };
const color Colors::blanchedAlmond = { 1.0f, 0.922f, 0.804f, 1.0f };
const color Colors::blue = { 0.0f, 0.0f, 1.0f, 1.0f };
const color Colors::blueViolet = { 0.541f, 0.169f, 0.886f, 1.0f };
const color Colors::brown = { 0.647f, 0.165f, 0.165f, 1.0f };
const color Colors::burlyWood = { 0.871f, 0.722f, 0.529f, 1.0f };
const color Colors::cadetBlue = { 0.373f, 0.62f, 0.627f, 1.0f };
const color Colors::chartreuse = { 0.498f, 1.0f, 0.0f, 1.0f };
const color Colors::chocolate = { 0.824f, 0.412f, 0.118f, 1.0f };
const color Colors::coral = { 1.0f, 0.498f, 0.314f, 1.0f };
const color Colors::cornflowerBlue = { 0.392f, 0.584f, 0.929f, 1.0f };
const color Colors::cornsilk = { 1.0f, 0.973f, 0.863f, 1.0f };
const color Colors::crimson = { 0.863f, 0.078f, 0.235f, 1.0f };
const color Colors::cyan = { 0.0f, 1.0f, 1.0f, 1.0f };
const color Colors::darkBlue = { 0.0f, 0.0f, 0.545f, 1.0f };
const color Colors::darkCyan = { 0.0f, 0.545f, 0.545f, 1.0f };
const color Colors::darkGoldenrod = { 0.722f, 0.525f, 0.043f, 1.0f };
const color Colors::darkGray = { 0.663f, 0.663f, 0.663f, 1.0f };
const color Colors::darkGreen = { 0.0f, 0.392f, 0.0f, 1.0f };
const color Colors::darkKhaki = { 0.741f, 0.718f, 0.42f, 1.0f };
const color Colors::darkMagenta = { 0.545f, 0.0f, 0.545f, 1.0f };
const color Colors::darkOliveGreen = { 0.333f, 0.42f, 0.184f, 1.0f };
const color Colors::darkOrange = { 1.0f, 0.549f, 0.0f, 1.0f };
const color Colors::darkOrchid = { 0.6f, 0.196f, 0.8f, 1.0f };
const color Colors::darkRed = { 0.545f, 0.0f, 0.0f, 1.0f };
const color Colors::darkSalmon = { 0.914f, 0.588f, 0.478f, 1.0f };
const color Colors::darkSeaGreen = { 0.561f, 0.737f, 0.561f, 1.0f };
const color Colors::darkSlateBlue = { 0.282f, 0.239f, 0.545f, 1.0f };
const color Colors::darkSlateGray = { 0.184f, 0.31f, 0.31f, 1.0f };
const color Colors::darkTurquoise = { 0.0f, 0.808f, 0.82f, 1.0f };
const color Colors::darkViolet = { 0.58f, 0.0f, 0.827f, 1.0f };
const color Colors::deepPink = { 1.0f, 0.078f, 0.576f, 1.0f };
const color Colors::deepSkyBlue = { 0.0f, 0.749f, 1.0f, 1.0f };
const color Colors::dimGray = { 0.412f, 0.412f, 0.412f, 1.0f };
const color Colors::dodgerBlue = { 0.118f, 0.565f, 1.0f, 1.0f };
const color Colors::fireBrick = { 0.698f, 0.133f, 0.133f, 1.0f };
const color Colors::floralWhite = { 1.0f, 0.98f, 0.941f, 1.0f };
const color Colors::forestGreen = { 0.133f, 0.545f, 0.133f, 1.0f };
const color Colors::fuchsia = { 1.0f, 0.0f, 1.0f, 1.0f };
const color Colors::gainsboro = { 0.863f, 0.863f, 0.863f, 1.0f };
const color Colors::ghostWhite = { 0.973f, 0.973f, 1.0f, 1.0f };
const color Colors::gold = { 1.0f, 0.843f, 0.0f, 1.0f };
const color Colors::goldenrod = { 0.855f, 0.647f, 0.125f, 1.0f };
const color Colors::gray = { 0.502f, 0.502f, 0.502f, 1.0f };
const color Colors::green = { 0.0f, 0.502f, 0.0f, 1.0f };
const color Colors::greenYellow = { 0.678f, 1.0f, 0.184f, 1.0f };
const color Colors::honeydew = { 0.941f, 1.0f, 0.941f, 1.0f };
const color Colors::hotPink = { 1.0f, 0.412f, 0.706f, 1.0f };
const color Colors::indianRed = { 0.804f, 0.361f, 0.361f, 1.0f };
const color Colors::indigo = { 0.294f, 0.0f, 0.51f, 1.0f };
const color Colors::ivory = { 1.0f, 1.0f, 0.941f, 1.0f };
const color Colors::khaki = { 0.941f, 0.902f, 0.549f, 1.0f };
const color Colors::lavender = { 0.902f, 0.902f, 0.98f, 1.0f };
const color Colors::lavenderBlush = { 1.0f, 0.941f, 0.961f, 1.0f };
const color Colors::lawnGreen = { 0.486f, 0.988f, 0.0f, 1.0f };
const color Colors::lemonChiffon = { 1.0f, 0.98f, 0.804f, 1.0f };
const color Colors::lightBlue = { 0.678f, 0.847f, 0.902f, 1.0f };
const color Colors::lightCoral = { 0.941f, 0.502f, 0.502f, 1.0f };
const color Colors::lightCyan = { 0.878f, 1.0f, 1.0f, 1.0f };
const color Colors::lightGoldenrodYellow = { 0.98f, 0.98f, 0.824f, 1.0f };
const color Colors::lightGreen = { 0.565f, 0.933f, 0.565f, 1.0f };
const color Colors::lightGrey = { 0.827f, 0.827f, 0.827f, 1.0f };
const color Colors::lightPink = { 1.0f, 0.714f, 0.757f, 1.0f };
const color Colors::lightSalmon = { 1.0f, 0.627f, 0.478f, 1.0f };
const color Colors::lightSeaGreen = { 0.125f, 0.698f, 0.667f, 1.0f };
const color Colors::lightSkyBlue = { 0.529f, 0.808f, 0.98f, 1.0f };
const color Colors::lightSlateGray = { 0.467f, 0.533f, 0.6f, 1.0f };
const color Colors::lightSteelBlue = { 0.69f, 0.769f, 0.871f, 1.0f };
const color Colors::lightYellow = { 1.0f, 1.0f, 0.878f, 1.0f };
const color Colors::lime = { 0.0f, 1.0f, 0.0f, 1.0f };
const color Colors::limeGreen = { 0.196f, 0.804f, 0.196f, 1.0f };
const color Colors::linen = { 0.98f, 0.941f, 0.902f, 1.0f };
const color Colors::magenta = { 1.0f, 0.0f, 1.0f, 1.0f };
const color Colors::maroon = { 0.502f, 0.0f, 0.0f, 1.0f };
const color Colors::mediumAquamarine = { 0.4f, 0.804f, 0.667f, 1.0f };
const color Colors::mediumBlue = { 0.0f, 0.0f, 0.804f, 1.0f };
const color Colors::mediumOrchid = { 0.729f, 0.333f, 0.827f, 1.0f };
const color Colors::mediumPurple = { 0.576f, 0.439f, 0.859f, 1.0f };
const color Colors::mediumSeaGreen = { 0.235f, 0.702f, 0.443f, 1.0f };
const color Colors::mediumSlateBlue = { 0.482f, 0.408f, 0.933f, 1.0f };
const color Colors::mediumSpringGreen = { 0.0f, 0.98f, 0.604f, 1.0f };
const color Colors::mediumTurquoise = { 0.282f, 0.82f, 0.8f, 1.0f };
const color Colors::mediumViolet = { 0.78f, 0.082f, 0.522f, 1.0f };
const color Colors::midnightBlue = { 0.098f, 0.098f, 0.439f, 1.0f };
const color Colors::mintCream = { 0.961f, 1.0f, 0.98f, 1.0f };
const color Colors::mistyRose = { 1.0f, 0.894f, 0.882f, 1.0f };
const color Colors::moccasin = { 1.0f, 0.894f, 0.71f, 1.0f };
const color Colors::navajoWhite = { 1.0f, 0.871f, 0.678f, 1.0f };
const color Colors::navy = { 0.0f, 0.0f, 0.502f, 1.0f };
const color Colors::oldLace = { 0.992f, 0.961f, 0.902f, 1.0f };
const color Colors::olive = { 0.502f, 0.502f, 0.0f, 1.0f };
const color Colors::oliveDrab = { 0.42f, 0.557f, 0.137f, 1.0f };
const color Colors::orange = { 1.0f, 0.647f, 0.0f, 1.0f };
const color Colors::orangeRed = { 1.0f, 0.271f, 0.0f, 1.0f };
const color Colors::orchid = { 0.855f, 0.439f, 0.839f, 1.0f };
const color Colors::paleGoldenrod = { 0.933f, 0.91f, 0.667f, 1.0f };
const color Colors::paleGreen = { 0.596f, 0.984f, 0.596f, 1.0f };
const color Colors::paleTurquoise = { 0.686f, 0.933f, 0.933f, 1.0f };
const color Colors::paleVioletRed = { 0.859f, 0.439f, 0.576f, 1.0f };
const color Colors::papayaWhip = { 1.0f, 0.937f, 0.835f, 1.0f };
const color Colors::peachPuff = { 1.0f, 0.855f, 0.725f, 1.0f };
const color Colors::peru = { 0.804f, 0.522f, 0.247f, 1.0f };
const color Colors::pink = { 1.0f, 0.753f, 0.796f, 1.0f };
const color Colors::plum = { 0.867f, 0.627f, 0.867f, 1.0f };
const color Colors::powderBlue = { 0.69f, 0.878f, 0.902f, 1.0f };
const color Colors::purple = { 0.502f, 0.0f, 0.502f, 1.0f };
const color Colors::red = { 1.0f, 0.0f, 0.0f, 1.0f };
const color Colors::rosyBrown = { 0.737f, 0.561f, 0.561f, 1.0f };
const color Colors::royalBlue = { 0.255f, 0.412f, 0.882f, 1.0f };
const color Colors::saddleBrown = { 0.545f, 0.271f, 0.075f, 1.0f };
const color Colors::salmon = { 0.98f, 0.502f, 0.447f, 1.0f };
const color Colors::sandyBrown = { 0.957f, 0.643f, 0.376f, 1.0f };
const color Colors::seaGreen = { 0.18f, 0.545f, 0.341f, 1.0f };
const color Colors::seashell = { 1.0f, 0.961f, 0.933f, 1.0f };
const color Colors::sienna = { 0.627f, 0.322f, 0.176f, 1.0f };
const color Colors::silver = { 0.753f, 0.753f, 0.753f, 1.0f };
const color Colors::skyBlue = { 0.529f, 0.808f, 0.922f, 1.0f };
const color Colors::slateBlue = { 0.416f, 0.353f, 0.804f, 1.0f };
const color Colors::slateGray = { 0.439f, 0.502f, 0.565f, 1.0f };
const color Colors::snow = { 1.0f, 0.98f, 0.98f, 1.0f };
const color Colors::springGreen = { 0.0f, 1.0f, 0.498f, 1.0f };
const color Colors::steelBlue = { 0.275f, 0.51f, 0.706f, 1.0f };
const color Colors::tan = { 0.824f, 0.706f, 0.549f, 1.0f };
const color Colors::teal = { 0.0f, 0.502f, 0.502f, 1.0f };
const color Colors::thistle = { 0.847f, 0.749f, 0.847f, 1.0f };
const color Colors::tomato = { 1.0f, 0.388f, 0.278f, 1.0f };
const color Colors::turquoise = { 0.251f, 0.878f, 0.816f, 1.0f };
const color Colors::violet = { 0.933f, 0.51f, 0.933f, 1.0f };
const color Colors::wheat = { 0.961f, 0.871f, 0.702f, 1.0f };
const color Colors::white = { 1.0f, 1.0f, 1.0f, 1.0f };
const color Colors::whiteSmoke = { 0.961f, 0.961f, 0.961f, 1.0f };
const color Colors::yellow = { 1.0f, 1.0f, 0.0f, 1.0f };
const color Colors::yellowGreen = { 0.604f, 0.804f, 0.196f, 1.0f };